home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / include / netInet.h < prev    next >
C/C++ Source or Header  |  1992-08-07  |  18KB  |  602 lines

  1. /*
  2.  * netInet.h --
  3.  *
  4.  *    Declarations of data structures and constants for the DARPA Internet 
  5.  *    protocol suite.
  6.  *
  7.  * Copyright 1987, 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /sprite/src/lib/include/RCS/netInet.h,v 1.7 92/08/05 16:34:23 jhh Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _NETINET
  20. #define _NETINET
  21.  
  22. #include "machparam.h"
  23. #include "netEther.h"
  24.  
  25.  
  26. /*
  27.  * Definition of the 32-bit Internet Address.
  28.  */
  29.  
  30. typedef unsigned int Net_InetAddress;
  31.  
  32. /*
  33.  * Net_InetAddrCmp --
  34.  *
  35.  * Compare two internet addresses. Returns 0 if they are the same, 1 otherwise.
  36.  */
  37. #define Net_InetAddrCmp(a,b) ((a) != (b))
  38.  
  39. #define Net_InetAddrCopy(src, dest) ((dest) = (src))
  40.  
  41. /*
  42.  * Structure of the Ethernet Address Resolution Protocol and Reverse ARP 
  43.  * packets, according to RFC826 (ARP) and RFC903 (RARP).
  44.  */
  45. typedef struct { 
  46.     unsigned short    hardwareType;        /* "Hardware address space (e.g.
  47.                          * Ethernet, Packet Radio Net.)"
  48.                          */
  49.     unsigned short    protocolType;        /* "Protocol Address Space"
  50.                          * specifies format of protocol
  51.                          * addresses. Value is one
  52.                          * of the defined packet types 
  53.                          * in netEther.h. */
  54.     unsigned char    hardwareAddrLen;    /* length in bytes of hardware
  55.                          * addresses. */
  56.     unsigned char    protocolAddrLen;    /* length in bytes of protocol
  57.                          * addresses. */
  58.     unsigned short    opcode;            /* see below. */
  59. }  Net_ArpHeader;
  60.  
  61. typedef struct {
  62.     Net_EtherHdr    header;            /* packet header */
  63.     unsigned short    hardwareType;        /* "Hardware address space (e.g.
  64.                          * Ethernet, Packet Radio Net.)"
  65.                          */
  66.     unsigned short    protocolType;        /* "Protocol Address Space"
  67.                          * specifies format of protocol
  68.                          * addresses. Value is one
  69.                          * of the defined packet types 
  70.                          * in netEther.h. */
  71.     unsigned char    hardwareAddrLen;    /* length in bytes of hardware
  72.                          * addresses. */
  73.     unsigned char    protocolAddrLen;    /* length in bytes of protocol
  74.                          * addresses. */
  75.     unsigned short    opcode;            /* see below. */
  76.     Net_EtherAddress    senderEtherAddr;    /* hardware address of sender
  77.                          * of the packet. */
  78.     Net_InetAddress    senderProtAddr;        /* protocol address of sender
  79.                          * of the packet. */
  80.     Net_EtherAddress    targetEtherAddr;    /* hardware address of target
  81.                          * (if known). */
  82.     Net_InetAddress    targetProtAddr;        /* protocol address of target.*/
  83. } Net_ArpPacket;
  84.  
  85. /*
  86.  * Value for the hardwareType field in Net_ArpPacket.
  87.  *   NET_ARP_TYPE_ETHER         using ethernet hardware.
  88.  */
  89.  
  90. #define NET_ARP_TYPE_ETHER    1
  91.  
  92. /*
  93.  * Values for the opcode field in Net_ArpPacket:
  94.  *   NET_ARP_REQUEST        request ethernet address for a given IP address.
  95.  *   NET_ARP_REPLY        answer for above request.
  96.  *   NET_RARP_REQUEST        request IP address for a given ethernet address.
  97.  *   NET_RARP_REPLY        answer for above request.
  98.  */
  99.  
  100. #define NET_ARP_REQUEST        1
  101. #define NET_ARP_REPLY        2
  102. #define NET_RARP_REQUEST    3
  103. #define NET_RARP_REPLY        4
  104.  
  105.  
  106.  
  107. #define NET_INET_BROADCAST_ADDR        ((Net_InetAddress) 0xFFFFFFFF)
  108. #define NET_INET_ANY_ADDR        ((Net_InetAddress) 0)
  109.  
  110. #define NET_INET_CLASS_A_ADDR(addr) \
  111.             (((unsigned int)(addr) & 0x80000000) == 0)
  112. #define NET_INET_CLASS_A_HOST_MASK        0x00FFFFFF
  113. #define NET_INET_CLASS_A_NET_MASK        0xFF000000
  114. #define NET_INET_CLASS_A_SHIFT            24
  115.  
  116. #define NET_INET_CLASS_B_ADDR(addr) \
  117.             (((unsigned int)(addr) & 0xC0000000) == 0x80000000)
  118. #define NET_INET_CLASS_B_HOST_MASK        0x0000FFFF
  119. #define NET_INET_CLASS_B_NET_MASK        0xFFFF0000
  120. #define NET_INET_CLASS_B_SHIFT            16
  121.  
  122. #define NET_INET_CLASS_C_ADDR(addr) \
  123.             (((unsigned int)(addr) & 0xE0000000) == 0xC0000000)
  124. #define NET_INET_CLASS_C_HOST_MASK        0x000000FF
  125. #define NET_INET_CLASS_C_NET_MASK        0xFFFFFF00
  126. #define NET_INET_CLASS_C_SHIFT            8
  127.  
  128. /*
  129.  * Class D: multicast addressing (see RFC988, RFC966).
  130.  */
  131. #define NET_INET_CLASS_D_ADDR(addr) \
  132.             (((unsigned int)(addr) & 0xF0000000) == 0xE0000000)
  133. #define NET_INET_CLASS_D_NET_MASK        0x0FFFFFFF
  134.  
  135. /*
  136.  * Class E: reserved.
  137.  */
  138. #define NET_INET_CLASS_E_ADDR(addr) \
  139.             (((unsigned int)(addr) & 0xF0000000) == 0xF0000000)
  140.  
  141. /*
  142.  * Synonym address for the local host.
  143.  */
  144. #define NET_INET_LOCAL_HOST        0x7F000001
  145.  
  146.  
  147.  
  148. /*
  149.  * Structure of an Internet packet header, according to RFC791.
  150.  */
  151.  
  152. typedef struct {
  153. #if  BYTE_ORDER == LITTLE_ENDIAN
  154.     unsigned int    headerLen:4,    /* Length of header in 32-bit words. */
  155.             version:4;    /* Version. Defined below. */
  156. #else
  157.     unsigned int    version:4,
  158.             headerLen:4;
  159. #endif
  160.     unsigned char    typeOfService;    /* See below. */
  161.     unsigned short    totalLen;    /* Length in bytes of the 
  162.                      * datagram including header and data.*/
  163.     unsigned short    ident;        /* Used for fragmentation reassembly. */
  164. #if BYTE_ORDER == LITTLE_ENDIAN
  165.     unsigned int    fragOffset:13,    /* Offset from beginning of unfragmented
  166.                      * packet. */
  167.             flags:3;    /* Fragment flags. See below. */
  168. #else
  169.     unsigned int    flags:3,
  170.             fragOffset:13;
  171. #endif
  172.     unsigned char    timeToLive;    /* Max. time the packet is allowed to
  173.                      * be in the internet system. When TTL
  174.                      * goes to 0, the packet is destroyed.*/
  175.     unsigned char    protocol;    /* Protocol used in the data portion.
  176.                      * Defined below. */
  177.     unsigned short    checksum;    /* Checksum of the header. */
  178.     Net_InetAddress    source;        /* Source of the packet. */
  179.     Net_InetAddress    dest;        /* Destination of the packet. */
  180.     /*
  181.      * Options may follow at this point, before the data.
  182.      */
  183. } Net_IPHeader;
  184.  
  185. /*
  186.  * IP Pseudo Header is used by UDP and TCP checksums to make sure
  187.  * the packet is not mis-routed.
  188.  */
  189. typedef struct {
  190.     Net_InetAddress    source;        /* Source of the packet. */
  191.     Net_InetAddress    dest;        /* Destination of the packet. */
  192.     unsigned char    zero;        /* must be zero. */
  193.     unsigned char    protocol;    /* Protocol # (UDP, TCP). */
  194.     unsigned short    len;        /* # of bytes in header and data. */
  195. } Net_IPPseudoHdr;
  196.  
  197. #define NET_IP_VERSION        4
  198. #define NET_IP_MAX_HDR_SIZE    60
  199.  
  200. /*
  201.  * IP implementation parameters:
  202.  *  NET_IP_MAX_TTL        - Max. value for timeToLive field (in seconds).
  203.  *  NET_IP_MAX_FRAG_TTL        - Max. time-to-live for fragments.
  204.  *  NET_IP_TTL_DECR        - The value ttl is decremented by when a 
  205.  *                   packet is forwarded.
  206.  *  NET_IP_MAX_SEG_SIZE        - Max. segment size.
  207.  *  NET_IP_MAX_PACKET_SIZE    - Largest packet size.
  208.  */
  209.  
  210. #define NET_IP_MAX_TTL            255
  211. #define NET_IP_MAX_FRAG_TTL        15
  212. #define NET_IP_TTL_DECR            1
  213. #define NET_IP_MAX_SEG_SIZE        576
  214. #define NET_IP_MAX_PACKET_SIZE        65535
  215.  
  216. /*
  217.  * Definitions of the typeOfService flags in the Internet header.
  218.  * According to p. 12 of RFC791, the type of service field has the
  219.  * the following subfields:
  220.  *    precedence:    bits 0-2    (most sig. bits)
  221.  *     delay        bit  3
  222.  *     thruput        bit  4
  223.  *     reliability    bit  5
  224.  *     reserved    bit  6-7    (least sig. bits)
  225.  * The value must be composed of the OR of one flag from each of the following
  226.  * groups:
  227.  */
  228.  
  229. #define NET_IP_SERV_PREC_NET_CTL    0xE0
  230. #define NET_IP_SERV_PREC_INET_CTL    0xC0
  231. #define NET_IP_SERV_PREC_CRITIC        0xA0
  232. #define NET_IP_SERV_PREC_FLASH_OVR    0x80
  233. #define NET_IP_SERV_PREC_FLASH        0x60
  234. #define NET_IP_SERV_PREC_IMMED        0x40
  235. #define NET_IP_SERV_PREC_PRIORITY    0x20
  236. #define NET_IP_SERV_PREC_ROUTINE    0x00
  237.  
  238. #define NET_IP_SERV_NORM_DELAY        0x00
  239. #define NET_IP_SERV_LOW_DELAY        0x10
  240.  
  241. #define NET_IP_SERV_NORM_THRUPUT    0x00
  242. #define NET_IP_SERV_HIGH_THRUPUT    0x08
  243.  
  244. #define NET_IP_SERV_NORM_RELIABL    0x00
  245. #define NET_IP_SERV_HIGH_RELIABL    0x04
  246.  
  247. /*
  248.  * Values for the flags field in the IP header.
  249.  *    NET_IP_LAST_FRAG    last fragment of the bunch. implies the
  250.  *                packet can be fragmented if necessary.
  251.  *    NET_IP_MORE_FRAGS    expect more fragments.
  252.  *    NET_IP_DONT_FRAG    the can't be fragmented so discard if can't
  253.  *                transmit.
  254.  *
  255.  * The high-order bit of the field must be 0.
  256.  */
  257.  
  258. #define NET_IP_LAST_FRAG        0x0
  259. #define NET_IP_MORE_FRAGS        0x1
  260. #define NET_IP_DONT_FRAG        0x2
  261.  
  262.  
  263. /*
  264.  * Values for the protocol field in the IP packet header from RFC990.
  265.  * The RFC does not assign a number for IP, so we use 0 (even though
  266.  * it is reserved).
  267.  */
  268.  
  269. #define NET_IP_PROTOCOL_IP        0
  270. #define NET_IP_PROTOCOL_ICMP        1
  271. #define NET_IP_PROTOCOL_TCP        6
  272. #define NET_IP_PROTOCOL_EGP        8
  273. #define NET_IP_PROTOCOL_UDP        17
  274. #define NET_IP_PROTOCOL_SPRITE        90
  275.  
  276.  
  277. /*
  278.  * Definitions of IP options.
  279.  * There are two formats for the options:
  280.  *   1) single octet of option-type.
  281.  *   2) an option-type octet, an option length, and the actual data octets.
  282.  *
  283.  * The option type is composed of 3 fields: copied flag (1 bit), 
  284.  * option class (2 bits), and an option number (5 bits).
  285.  */
  286.  
  287. /*
  288.  * Definitions of offsets within an option for the type, length and next-
  289.  * option-offset octets. The minimum value for the next-option offset 
  290.  * ("pointer") is 4.  The pointer is used in the 3 routing options and 
  291.  * the timestamp option.
  292.  */
  293. #define NET_IP_OPT_TYPE_OFFSET        0
  294. #define NET_IP_OPT_LEN_OFFSET        1
  295. #define NET_IP_OPT_PTR_OFFSET        2
  296. #define NET_IP_OPT_MIN_PTR        4
  297.  
  298. #define NET_IP_OPT_MAX_LEN        40
  299.  
  300. /*
  301.  * Macros to access the option-type fields.
  302.  *  NET_IP_OPT_COPIED    - 0 means not copied, 1 means copied.
  303.  *  NET_IP_OPT_CLASS    - see below.
  304.  *  NET_IP_OPT_NUMBER    - see below.
  305.  */
  306.  
  307. #define NET_IP_OPT_COPIED(opt)        ((opt) & 0x80)
  308. #define NET_IP_OPT_CLASS(opt)        ((opt) & 0x60)
  309. #define NET_IP_OPT_NUMBER(opt)        ((opt) & 0x1f)
  310.  
  311. /*
  312.  * Values for NET_IP_OPT_CLASS as masks.
  313.  */
  314. #define NET_IP_OPT_CLASS_CONTROL        0x00
  315. #define NET_IP_OPT_CLASS_RESERVED1        0x20
  316. #define NET_IP_OPT_CLASS_DEBUG            0x40
  317. #define NET_IP_OPT_CLASS_RESERVED2        0x60
  318.  
  319. /*
  320.  * Complete values for the option types, including the copied and class fields
  321.  * as well as the number field.   The definitions are listed in the same 
  322.  * order as described in RFC791, p. 16ff.
  323.  */
  324.  
  325. #define NET_IP_OPT_END_OF_LIST        0x00
  326. #define NET_IP_OPT_NOP            0x01
  327. #define NET_IP_OPT_SECURITY        0x82
  328. #define NET_IP_OPT_LOOSE_ROUTE        0x83
  329. #define NET_IP_OPT_STRICT_ROUTE        0x89
  330. #define NET_IP_OPT_REC_ROUTE        0x07
  331. #define NET_IP_OPT_STREAM_ID        0x88
  332. #define NET_IP_OPT_TIMESTAMP        0x44
  333.  
  334. /*
  335.  * Foramt of the timestamp option header.
  336.  */
  337. typedef struct {
  338.     unsigned char    type;
  339.     unsigned char    len;            /* Total len of option. */
  340.     unsigned char    pointer;        /* Offset into option where
  341.                          * to add t.s. */
  342. #if  BYTE_ORDER == LITTLE_ENDIAN
  343.     unsigned int    flags:4,        /* Defined below. */
  344.             overflow:4;        /* # of hosts who weren't
  345.                          * able to add a t.s. */
  346. #else
  347.     unsigned int    overflow:4,
  348.             flags:4;
  349. #endif
  350. } Net_IPTimestampHdr;
  351.  
  352. /*
  353.  *  Values of the flags field in Net_IPTimestampHdr.
  354.  */
  355. #define NET_IP_OPT_TS_ONLY        0
  356. #define NET_IP_OPT_TS_AND_ADDR        1
  357. #define NET_IP_OPT_TS_ADDR_SPEC        3
  358.  
  359. /*
  360.  * Interet time value is a "right-justified, 32-bit" time in milliseconds
  361.  * since midnight Universal Time (UT).
  362.  */
  363. typedef int Net_InetTime;
  364.  
  365.  
  366. /*
  367.  * Structure of an TCP packet header, according to RFC793.
  368.  */
  369.  
  370. typedef struct {
  371.     unsigned short    srcPort;    /* Source port # */
  372.     unsigned short    destPort;    /* Destination port # */
  373.     unsigned int    seqNum;        /* Seq. # of 1st byte in the segment */
  374.     unsigned int    ackNum;        /* Next seq. # we expect */
  375. #if BYTE_ORDER == LITTLE_ENDIAN
  376.     unsigned int    reserved1:4,    /* Must be zero. */
  377.             dataOffset:4,    /* # of 32-bit words in this header */
  378.             flags:6,    /* Control flags, define below. */
  379.             reserved2:2;    /* Must be zero */
  380. #else
  381.     unsigned int    dataOffset:4,
  382.             reserved:6,
  383.             flags:6;
  384. #endif
  385.     unsigned short    window;        /* # of bytes we are willing to accept*/
  386.     unsigned short    checksum;    /* Checksum of IP pseudo-header, 
  387.                      * TCP header and data. */
  388.     unsigned short    urgentOffset;    /* Start of urgent data as an offset
  389.                      * from the seq. # of this segment. */
  390. } Net_TCPHeader;
  391.  
  392. #define NET_TCP_MAX_HDR_SIZE    60
  393. #define NET_TCP_TTL        30
  394.  
  395. /*
  396.  * TCP header control flags: (p. 16, rfc793)
  397.  *
  398.  *    URG -  Urgent Pointer field significant
  399.  *    ACK -  Acknowledgment field significant
  400.  *    PSH -  Push Function
  401.  *    RST -  Reset the connection
  402.  *    SYN -  Synchronize sequence numbers
  403.  *    FIN -  No more data from sender
  404.  */
  405.  
  406. #define NET_TCP_FIN_FLAG    0x01
  407. #define NET_TCP_SYN_FLAG    0x02
  408. #define NET_TCP_RST_FLAG    0x04
  409. #define NET_TCP_PSH_FLAG    0x08
  410. #define NET_TCP_ACK_FLAG    0x10
  411. #define NET_TCP_URG_FLAG    0x20
  412.  
  413.  
  414. /*
  415.  * TCP options flags:        (p. 16, rfc793)
  416.  *    EOL        - End of option list
  417.  *    NOP        - No-operation
  418.  *    MAX_SEG_SIZE    - Maximum segment size
  419.  */
  420.  
  421. #define NET_TCP_OPTION_EOL        0x0
  422. #define NET_TCP_OPTION_NOP        0x1
  423. #define NET_TCP_OPTION_MAX_SEG_SIZE    0x2
  424.  
  425. #define NET_TCP_MAX_SEG_SIZE        512
  426.  
  427.  
  428.  
  429. /*
  430.  * Structure of an UDP packet header, according to RFC768.
  431.  */
  432.  
  433. typedef struct {
  434.     unsigned short    srcPort;    /* Source port. */
  435.     unsigned short    destPort;    /* Destination port. */
  436.     unsigned short    len;        /* # of bytes in header and data. */
  437.     unsigned short    checksum;    /* Checksum of IP pseudo-header,
  438.                      * UDP header and data. */
  439. } Net_UDPHeader;
  440.  
  441. #define NET_UDP_TTL            30
  442.  
  443.  
  444. /*
  445.  * Structure of various ICMP packets, according to RFC792.
  446.  * The data structures for ICMP data is broken into 2 parts: 
  447.  * a 4-byte header that is common to all ICMP packet types and
  448.  * a type-dependent data part.
  449.  *
  450.  * The packets that include the IP header + the first 64 bits of data
  451.  * consist of the basic header, plus room for the header options followed
  452.  * by space for the data. Enough space to hold the maximum amount of
  453.  * header options is reserved; if the size of the options is smaller than
  454.  * maximum, the 64 bits of data will be placed immediately after the end
  455.  * of the options. Therefore the "char data[8]" field is there to reserve
  456.  * space in case of a maximum-sized header is present.
  457.  */
  458.  
  459. typedef struct {
  460.     unsigned char    type;        /* Type of message, define below. */
  461.     unsigned char    code;        /* Type sub code, define below. */
  462.     unsigned short    checksum;    /* Checksum of ICMP message. */
  463. } Net_ICMPHeader;
  464.  
  465. /*
  466.  * Data for "Destination unreachable", "Time exceeded", 
  467.  *  "Source Quench" messages.
  468.  */
  469. typedef struct {
  470.     int            unused;    
  471.     Net_IPHeader    ipHeader;
  472.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  473.     char        data[8];
  474. } Net_ICMPDataMisc;
  475.  
  476. /*
  477.  * Data for "Redirect" message.
  478.  */
  479. typedef struct {
  480.     Net_InetAddress    gatewayAddr;
  481.     Net_IPHeader    ipHeader;
  482.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  483.     char        data[8];
  484. } Net_ICMPDataRedir;
  485.  
  486. /*
  487.  * Data for "Parameter Problem" message.
  488.  */
  489. typedef struct {
  490.     unsigned char    paramOffset;
  491.     char        unused1;
  492.     short        unused2;
  493.     Net_IPHeader    ipHeader;
  494.     char        hdrOptions[NET_IP_MAX_HDR_SIZE - sizeof(Net_IPHeader)];
  495.     char        data[8];
  496. } Net_ICMPDataParam;
  497.  
  498. /*
  499.  * Data for "Information Request", "Information Reply", "Echo" and "Echo Reply"
  500.  * messages. The echo messages also have additional data following.
  501.  */
  502. typedef struct {
  503.     unsigned short    id;
  504.     unsigned short    seqNum;
  505. } Net_ICMPDataInfoEcho;
  506.  
  507.  
  508. /*
  509.  * Data for "Address Mask Request" and "Address Mask Reply" messages.
  510.  */
  511. typedef struct {
  512.     unsigned short    id;
  513.     unsigned short    seqNum;
  514.     unsigned int    addrMask;
  515. } Net_ICMPDataMask;
  516.  
  517. /*
  518.  * Data for "Timestamp" and "Timestamp Reply" message.
  519.  */
  520. typedef struct {
  521.     unsigned short    id;
  522.     unsigned short    seqNum;
  523.     unsigned int    origTime;
  524.     unsigned int    recvTime;
  525.     unsigned int    transmitTime;
  526. } Net_ICMPDataTime;
  527.  
  528.  
  529. /*
  530.  * A complete definition of an ICMP packet.
  531.  */
  532.  
  533. typedef struct {
  534.     Net_ICMPHeader    header;
  535.     union {
  536.     Net_ICMPDataMisc    overlay;    /* used to format packets that
  537.                          * return the IP header & data*/
  538.     Net_ICMPDataMisc    unreach;    /* NET_ICMP_UNREACHABLE */
  539.     Net_ICMPDataMisc    timeExceed;    /* NET_ICMP_TIME_EXCEED */
  540.     Net_ICMPDataMisc    quench;        /* NET_ICMP_SOURCE_QUENCH */
  541.     Net_ICMPDataParam    param;        /* NET_ICMP_PARAM_PROB */
  542.     Net_ICMPDataRedir    redirect;    /* NET_ICMP_REDIRECT */
  543.     Net_ICMPDataTime    timeStamp;    /* NET_ICMP_TIMESTAMP, _REPLY */
  544.     Net_ICMPDataMask    mask;        /* NET_ICMP_MASK_REQ, _REPLY */
  545.     Net_ICMPDataInfoEcho    info;        /* NET_ICMP_INFO_REQ , _REPLY */
  546.     Net_ICMPDataInfoEcho    echo;        /* NET_ICMP_ECHO, _REPLY */
  547.     } data;
  548. } Net_ICMPPacket;
  549.  
  550. #define NET_ICMP_MIN_LEN    8
  551.  
  552. /*
  553.  * Definition of type and code field values.
  554.  */
  555.  
  556. #define    NET_ICMP_ECHO_REPLY        0    /* Echo reply */
  557.  
  558. #define    NET_ICMP_UNREACHABLE        3    /* Dest unreachable, codes: */
  559. #define     NET_ICMP_UNREACH_NET           0    /*  - Bad net */
  560. #define     NET_ICMP_UNREACH_HOST           1    /*  - Bad host */
  561. #define     NET_ICMP_UNREACH_PROTOCOL       2    /*  - Bad protocol */
  562. #define     NET_ICMP_UNREACH_PORT           3    /*  - Bad port */
  563. #define     NET_ICMP_UNREACH_NEED_FRAG       4    /*  - IP_DF caused drop */
  564. #define     NET_ICMP_UNREACH_SRC_ROUTE       5    /*  - Source route failed */
  565.  
  566. #define    NET_ICMP_SOURCE_QUENCH        4    /* Source quench */
  567. #define    NET_ICMP_REDIRECT        5    /* Shorter route, codes: */
  568. #define     NET_ICMP_REDIRECT_NET           0    /*  - For network */
  569. #define     NET_ICMP_REDIRECT_HOST           1    /*  - For host */
  570. #define     NET_ICMP_REDIRECT_TOS_NET       2    /*  - For type of service and 
  571.                          *    net. */
  572. #define     NET_ICMP_REDIRECT_TOS_HOST       3    /*  - For type of service and 
  573.                          *     host. */
  574. #define    NET_ICMP_ECHO            8    /* Echo service */
  575. #define    NET_ICMP_TIME_EXCEED        11    /* Time exceeded, code: */
  576. #define     NET_ICMP_TIME_EXCEED_TTL       0    /*  - ttl==0 in transit */
  577. #define     NET_ICMP_TIME_EXCEED_REASS       1    /*  - ttl==0 in reassembly */
  578. #define    NET_ICMP_PARAM_PROB        12    /* IP header bad */
  579. #define    NET_ICMP_TIMESTAMP        13    /* Timestamp request */
  580. #define    NET_ICMP_TIMESTAMP_REPLY    14    /* Timestamp reply */
  581. #define    NET_ICMP_INFO_REQ        15    /* Information request */
  582. #define    NET_ICMP_INFO_REPLY        16    /* Information reply */
  583. #define    NET_ICMP_MASK_REQ        17    /* Address mask request */
  584. #define    NET_ICMP_MASK_REPLY        18    /* Address mask reply */
  585.  
  586. #define    NET_ICMP_MAX_TYPE        18
  587.  
  588.  
  589. /*
  590.  * Definition of a socket address. To be compatible with the Unix sockaddr_in
  591.  * structure, there are address family and padding fields. They aren't used
  592.  * by the Sprite Internet server.
  593.  */
  594. typedef struct {
  595.     short        addrFamily;    /* For Unix compatibilty, == AF_INET */
  596.     unsigned short    port;
  597.     Net_InetAddress    address;
  598.     char        padding[8];    /* Not used. */
  599. } Net_InetSocketAddr;
  600.  
  601. #endif /* _NETINET */
  602.